package com.darren.befriend.fragments;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import com.darren.befriend.BaseActivity;
import com.darren.befriend.HomeActivity;
import com.darren.befriend.R;
import com.darren.befriend.UserSettingInitialActivity;
import com.darren.befriend.constants.Constant;

public class FilmFragment extends HobbyBaseFragment {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		interestTextArr = getResources().getStringArray(R.array.film_text_arr);
		mInterestResIds = new int[] { R.drawable.f0, R.drawable.f1,
				R.drawable.f2, R.drawable.f3, R.drawable.f4, R.drawable.f5,
				R.drawable.f6, R.drawable.f7, R.drawable.f8, R.drawable.f9,
				R.drawable.f10, R.drawable.f11, R.drawable.f12, R.drawable.f13,
				R.drawable.f14, R.drawable.f15, R.drawable.f16, R.drawable.f17,
				R.drawable.f18, R.drawable.f19, R.drawable.f20, R.drawable.f21,
				R.drawable.f22, R.drawable.f23, R.drawable.f24 };
		if (getArguments() != null) {

			MODE_VALUE = getArguments().getInt(MODE, 0);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {

		mCurrentUser = ((BaseActivity) getActivity()).getCurrentUser();
		if (mCurrentUser != null) {

			mSelected = (ArrayList<Boolean>) mCurrentUser.get("FILMS");
		}

		super.onActivityCreated(savedInstanceState);
		mTitle = getString(R.string.film);
		if (getActivity() instanceof UserSettingInitialActivity) {
			((UserSettingInitialActivity) getActivity())
					.setActivityTitle(mTitle);
			if (MODE_VALUE == FIRST_MODE) {

				((UserSettingInitialActivity) getActivity())
						.setNavigationImage(R.drawable.item_sport_b,
								R.drawable.item_music);
			} else if (MODE_VALUE == SECOND_MODE) {

				((UserSettingInitialActivity) getActivity())
						.setNavigationImage(R.drawable.item_back,
								Integer.MAX_VALUE);
			}
		} else if (getActivity() instanceof HomeActivity) {

			((HomeActivity) getActivity()).showRightButtonImg(false);
			((HomeActivity) getActivity()).setLeftImage(R.drawable.item_back);
			((HomeActivity) getActivity()).setActivityTitle(mTitle);
		}
	}

	@Override
	public void onClick(View v) {
		HOBBY_TYPE = Constant.FILM;
		super.onClick(v);
	}

	public static Fragment create(int mode) {
		FilmFragment fragment = new FilmFragment();
		Bundle bundle = new Bundle();
		bundle.putInt(MODE, mode);
		fragment.setArguments(bundle);
		return fragment;
	}
}
